package pw.hais.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * android:layout_centerInParent="true"
 * Created by Hais1992 on 2015/11/2.
 */
public class TextImageButtonView extends RelativeLayout {
    private ImageView imageViewbutton;
    private TextView textView;

    public TextImageButtonView(Context context, AttributeSet attrs) {
        super(context);
        // TODO Auto-generated constructor stub

        //布局
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_IN_PARENT);

        //按钮
        imageViewbutton = new ImageView(context, attrs);
        imageViewbutton.setPadding(0, 0, 0, 0);
        //文字
        textView = new TextView(context, attrs);
        textView.setGravity(Gravity.CENTER);
        textView.setPadding(0, 0, 0, 0);

        setClickable(true);
        setFocusable(true);

        //setBackgroundResource(android.R.drawable.btn_default);

        //setOrientation(RelativeLayout.CENTER_IN_PARENT);

        addView(imageViewbutton,params);
        addView(textView,params);
    }
}
